package com.wx.controller.api;

import com.wx.common.WrapMapper;
import com.wx.common.Wrapper;
import com.wx.entity.SysAeReportLog;
import com.wx.holder.WxUserHolder;
import com.wx.service.SysAeReportLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>Title:      ApiAeReportLogController. </p>
 * <p>Description AE上报管理 </p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company:    医百科技有限公司 </p>
 *
 * @author         <a href="yangwensheng@100doc.com.cn"/>杨文生</a>
 * @since      2021/3/27 14:10
 */
@RestController
@RequestMapping(value = "/api/aeReport", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(tags = "AE上报管理(API)", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ApiAeReportLogController {

    @Resource
    private SysAeReportLogService sysAeReportLogService;

    @Resource
    private WxUserHolder wxUserHolder;


    @PostMapping("/add")
    @ApiOperation(httpMethod = "POST", value = "AE上报")
    public Wrapper<?> add(@ApiParam(name = "sysAeReportLog", value = "sysAeReportLog") @RequestBody SysAeReportLog sysAeReportLog) {
        WxOAuth2UserInfo userInfo = wxUserHolder.getUserInfo();
        sysAeReportLog.setOpenId(userInfo.getOpenid());
        int result = sysAeReportLogService.sysAeReportLog(sysAeReportLog);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE,result);
    }

}
